﻿#include <iostream>
using namespace std;
typedef long long LL;
const int N = 1e5+1;
int a[N], b[N], x[N], y[N];
int main()
{
    int n ; cin >> n;
    int i = 1;
    for (i = 1; i <= n; i++)
    {
        cin >> x[i] >> y[i] >> a[i] >> b[i];
    }
    int cx, cy;
    cin >>  cx >> cy;
    for (i = n; i >= 1; --i)
    {
        if (cx >= x[i] && cx <= x[i] + a[i])
        {
            if (cy >= y[i] && cy <= b[i] + y[i])
            {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1;
    return 0;
}